import java.util.Scanner;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-04-30
 * Time: 10:06
 */
public class TestDemo {
    //打印素数:1~100
    public static void main(String[] args) {
        int i = 0;
        int j = 0;
        boolean flag = true;
        for (i = 2; i <= 100; i++) {
            for ( j = 2; j < i; j++) {
                if(i%j == 0){
                    flag = false;
                    break;
                }
            }
            //这里跳出循环有两种情况：1.j超出了100（i是素数） 2.j没有超出100（i不是素数）
            if(flag == false){
                System.out.print(i );
            }
        }
    }




    //求最大公约数
    public static void main3(String[] args) {
        int a = 8;
        int b = 12;
        int m = a%b;
        //辗转相除法
        while(m != 0){
            a = b;
            b = m;
            m = a%b;
        }
        System.out.println("最大公约数"+b);
    }



        public static void main2(String[] args){
            //多组输入
            Scanner sc = new Scanner(System.in);
            while (sc.hasNextInt()){
                int n = sc.nextInt();
                for(int i = 0; i < n; i++){
                    for(int j = 0; j < n; j++){
                        if((i+j == n-1) || i==j){
                            System.out.print("*");
                        }
                        else{
                            System.out.print(" ");
                        }
                    }
                    System.out.print("\n");
                }
            }
        }

    //1.求出位数:除十
    //2.求幂
    //3.判断是否相等
    public static void main1(String[] args) {
        //产生6位数
        int count = 0;
        int tmp = 0;
        int sum = 0;
        for (int i = 0; i < 999999; i++) {//153
            tmp = i;
            //求位数
            while(tmp != 0){//153
                tmp /= 10;
                count++;
            }
            //求幂
            tmp = i;
            while(tmp != 0){
                sum += Math.pow(tmp%10,count);
                tmp /= 10;
            }
            //判断是否相等
            if(i == sum){
                System.out.println(i);
            }
            //注意判断完一个数字后，sum和count都需要重置来进行下次下一个数字的判断换
            sum = 0;
            count = 0;
        }
    }
}
